﻿@model EvertonApp.AdminWeb.Models.ComercioModel

<script type="text/javascript">
    var jQuery = {};
</script>

<center>
<div id="divGridOfertas">
    @if (@Model.Ofertas != null && @Model.Ofertas.Count() > 0)
    {
        WebGrid grid = new WebGrid(defaultSort: "", rowsPerPage: 8, ajaxUpdateContainerId: "divGridOfertas");
        grid.Bind(Model.Ofertas, autoSortAndPage: true, rowCount: Model.Ofertas.Count());
        @grid.GetHtml(
            fillEmptyRows: false,
            tableStyle: "table table-striped table-bordered table-condensed",
            mode: WebGridPagerModes.All,
            //firstText: "<< Primera",
            //previousText: "< Anterior",
            //nextText: "Siguiente >",
            //lastText: "Última >>",
            columns: new[]{
                //grid.Column("IdComercio",header: "Nº Comercio", canSort: false),
                grid.Column("Titulo",header: "Titulo", canSort: false),
                grid.Column("Descripcion",header: "Descripción", canSort: false),
                grid.Column("FechaInicio",header: "Fecha de Inicio", canSort: false, format: @<text>@item.FechaInicio.ToString("dd/MM/yyyy")</text>),
                grid.Column("FechaFin",header: "Fecha Fin", canSort: false, format: @<text>@item.FechaInicio.ToString("dd/MM/yyyy")</text>),  
                grid.Column("",header: "Acciones", format:@<text>
@*                                                               @Ajax.ActionLink("Ver", "Details", "Comercio2", new { id = item.IdComercio }, new AjaxOptions{  HttpMethod = "GET", UpdateTargetId = "myModal", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup"} )*@
                                                               @Ajax.ActionLink("Eliminar", "DeleteOferta", "Comercio2", new { IdOferta = item.IdOferta }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divGridOfertas", OnComplete="limpiarCampos();" })
                                                               @Ajax.ActionLink("Editar", "EditOferta", "Comercio2", new { IdOferta = item.IdOferta, Titulo = item.Titulo, Descripcion = item.Descripcion, FechaInicio = item.FechaInicio, FechaFin = item.FechaFin }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "myModal", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopupOferta();limpiarCampos();"})
@*                                                                @Ajax.ActionLink("Gestionar Ofertas", "GestionarOfertas", "Comercio2", new { IdComercio = item.IdComercio }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "global"})*@

                                                           </text> )}
        )
    }
    else
    {
        <label>No se han encontrado ofertas.</label>
    }
</div>
</center> 